package controller;

import entity.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import vo.AjaxResult;

import java.awt.*;
import java.util.Date;

/**
 * Author：汤小洋
 * Date：2023-08-14 14:52
 * Description：<描述>
 */
// @Controller
// @ResponseBody
@RestController // @Controller + @ResponseBody
// @CrossOrigin // 允许跨域
public class AjaxController {

    // @ResponseBody
    @RequestMapping("/ajax1")
    public User ajax1(){
        System.out.println("AjaxController.ajax1...........");
        return new User(101,"汤小洋","123456",18,new Date());
    }

    @RequestMapping("/ajax2")
    public AjaxResult ajax2(){
        User user = new User(101, "汤小洋", "123456", 18, new Date());

        return AjaxResult.success(user);
    }
}
